<?php
declare (strict_types = 1);

namespace app\adminapi\controller\organize;

use adminmatrix\admin\BaseController;
use adminmatrix\admin\service\JsonService;
use app\adminapi\logic\organize\AdminPositionLogic;

use think\Request;
use think\response\Json;
use hg\apidoc\annotation as Apidoc;
#[
    Apidoc\Title("职位列表"),
    Apidoc\Group("organize")
]
class PositionController extends BaseController
{

    #[
        Apidoc\Title("获取列表"),
        Apidoc\Tag("职位列表")
    ]
    public function lists(){
        return $this->dataLists();
    }

    #[
        Apidoc\Title("新增职位"),
        Apidoc\Method("POST"),
        Apidoc\Author("Xiaobin"),
        Apidoc\Tag("职位列表")
    ]
    public function save(Request $request , AdminPositionLogic $logic) : Json
    {
        try {
            $logic->save($request);
            return JsonService::success('新增职位成功');
        } catch (\Exception $e)
        {
            return JsonService::fail($e->getMessage());
        }
    }

    #[
        Apidoc\Title("更新职位"),
        Apidoc\Method("PUT"),
        Apidoc\Author("Xiaobin"),
        Apidoc\Tag("职位列表")
    ]
    public function update(Request $request ,AdminPositionLogic $logic) : Json
    {
        try {
            $logic->update($request);
            return JsonService::success('更新职位成功');
        } catch (\Exception $e)
        {
            return  JsonService::fail($e->getMessage());
        }
    }

    #[
        Apidoc\Title("删除职位"),
        Apidoc\Method("DELETE"),
        Apidoc\Author("Xiaobin"),
        Apidoc\Tag("职位列表")
    ]
    public function delete(Request $request ,AdminPositionLogic $logic) : Json
    {
        try {
            $logic->delete($request);
            return JsonService::success('删除职位成功');
        } catch (\Exception $e)
        {
            return JsonService::fail($e->getMessage());
        }
    }


}
